#!/bin/bash
echo -e "==================== server release start ===================="
#切换分支并拉去代码
echo -e "切换到源码目录 ..."
cd /app/code/chandao_server
echo -e "开始切换分支 ..."
git checkout -b release origin/master
echo -e "开始pull代码 ..."
git pull
echo -e "Pull代码成功!!! "
echo -e "开始编译代码 ... "
mvn clean install -am -DskipTests=true
echo -e "编译代码成功 ... "
echo -e "开始复制jar包到运行目录 ... "
cd /app/code/chandao_server/target
cp chandao_server.jar /app/chandao_test/server/chandao_server_test.jar
echo -e "复制jar包成功 ... "
cd /app/chandao_test/server
chmod 777 chandao_server_test.jar
pid=$(ps -ef|grep java|grep -v "grep"|grep chandao_server_test.jar|awk '{print $2}')
kill -9 $pid
echo -e "开始运行 ... "
nohup java -jar -Dspring.profiles.active=dev chandao_server_test.jar &
tail -f nohup.out
echo -e "==================== pms-server release success ===================="
